import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'routes.dart';

class SplashPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _PageState();
}

class _PageState extends State<SplashPage> {
  @override
  Widget build(BuildContext context) {
    // Set the fit size (fill in the screen size of the device in the design)
    // If the design is based on the size of the iPhone6 ​​(iPhone6 ​​750*1334)
    ScreenUtil.init(context, width: 750, height: 1334);
    return Scaffold(
      body: Image.asset(
        'images/icon_guide.png',
        width: double.infinity,
        height: double.infinity,
        fit: BoxFit.fill,
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    // 隐藏状态栏和导航栏
    SystemChrome.setEnabledSystemUIOverlays([]);

    Timer(Duration(seconds: 3), () {
      Navigator.of(context).pushReplacementNamed(homePage);
    });
  }

  @override
  void dispose() {
    super.dispose();
    // 恢复状态栏和导航栏
    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
  }
}
